﻿@model ProductDetailsModel
@inject SeoSettings seoSettings
@using Grand.Core;
@using Grand.Framework.Themes
@using Grand.Framework.UI
@inject IWorkContext workContext
@inject IThemeContext themeContext
@inject IPageHeadBuilder pagebuilder

@{
    Layout = "";
}
@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_quickview_after_breadcrumb", additionalData = Model.Id })
<b-modal ref="ModalQuickView" id="ModalQuickView" :dark-theme="darkMode" @@shown="onShown" size="xl" centered hide-footer hide-header>
    @{
        var supportRtl = workContext.WorkingLanguage.Rtl;
        if (supportRtl)
        {
            <link href="~/Themes/VueTheme/Content/css/product/product.rtl.css" rel="stylesheet" type="text/css" />
        }
        else
        {
            <link href="~/Themes/VueTheme/Content/css/product/product.css" rel="stylesheet" type="text/css" />
        }
    }
    <b-button class="modal-close" block @@click="$bvModal.hide('ModalQuickView')"><b-icon icon="x"></b-icon></b-button>
    <div class="page product-details-page">
        <vc:widget widget-zone="productdetails_top" additional-data="@Model.Id"></vc:widget>
        <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id="product-details-form">
            <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">
                <b-container class="position-relative">
                    <b-row>
                        <vc:widget widget-zone="productdetails_before_pictures" additional-data="@Model.Id"></vc:widget>
                        <!--product pictures-->
                        <partial name="_ProductDetailsPicturesQv" model="Model" />
                        <vc:widget widget-zone="productdetails_after_pictures" additional-data="@Model.Id"></vc:widget>
                        <b-col xl="7" lg="8" md="12" cols="12" class="overview pl-md-3 pl-0 pr-0">
                            @if (!string.IsNullOrEmpty(Model.Flag))
                            {
                                <div class="product-label">
                                    <b-badge variant="info">@Model.Flag</b-badge>
                                </div>
                            }
                            <partial name="_Discontinued" model="Model" />
                            <h1 class="generalTitle" itemprop="name">
                                @Model.Name
                            </h1>
                            <!--product reviews-->
                            @if (Model.ProductReviewOverview.AllowCustomerReviews)
                            {
                                <partial name="_ProductReviewOverview" model="Model.ProductReviewOverview" />
                            }
                            <vc:widget widget-zone="productdetails_overview_top" additional-data="@Model.Id"></vc:widget>
                            @if (!String.IsNullOrEmpty(Model.ShortDescription))
                            {
                                <div class="short-description generalMarginSupporter">
                                    @Html.Raw(Model.ShortDescription)
                                </div>
                            }
                            <!--manufacturers-->
                            @if (Model.ProductManufacturers.Any())
                            {
                                <partial name="_ProductManufacturers" model="Model.ProductManufacturers" />
                            }
                            <!--availability-->
                            @if (!String.IsNullOrWhiteSpace(Model.StockAvailability) || Model.DisplayBackInStockSubscription)
                            {
                                <partial name="_Availability" model="Model" />
                            }
                            <!--SKU, MAN, GTIN, vendor-->
                            <partial name="_SKU_Man_GTIN_Ven" model="Model" />
                            <!--delivery-->
                            @if ((Model.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(Model.DeliveryDate)
                            || Model.NotReturnable || Model.AdditionalShippingCharge > 0)
                            {
                                <partial name="_DeliveryInfo" model="Model" />
                            }
                            <!--sample download-->
                            @if (Model.HasSampleDownload)
                            {
                                <partial name="_DownloadSample" model="Model" />
                            }
                            <!--product bundles-->
                            @if (Model.ProductBundleModels.Any())
                            {
                                <partial name="_ProductBundles" model="Model" />
                            }
                            <!--attributes-->
                            @{
                                if (Model.ProductAttributes.Any())
                                {
                                    var dataDictAttributes = new ViewDataDictionary(ViewData);
                                    dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", Model.Id);
                                    <partial name="VueProductAttributes" model="Model.ProductAttributes" view-data="dataDictAttributes" />
                                }
                            }
                            <!--warehouses-->
                            @if (Model.AllowToSelectWarehouse)
                            {
                                <partial name="_ProductWarehouses" model="Model" />
                            }
                            <!--gift card-->
                            @{
                                if (Model.GiftCard.IsGiftCard)
                                {
                                    var dataDictGiftCard = new ViewDataDictionary(ViewData);
                                    dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", Model.Id);
                                    <partial name="_GiftCardInfo" model="Model.GiftCard" view-data="dataDictGiftCard" />
                                }
                            }
                            <!--reservation info-->
                            @if (Model.ProductType == ProductType.Reservation)
                            {
                                var dataDictReservation = new ViewDataDictionary(ViewData);
                                dataDictReservation.TemplateInfo.HtmlFieldPrefix = string.Format("reservation_{0}", Model.Id);
                                <partial name="_ReservationInfo" model="Model" view-data="dataDictReservation" />
                            }
                            <!--price & add to cart-->
                            <div class="overview-buttons generalMarginSupporter">
                                @if (Model.TierPrices.Any() && !(Model.TierPrices.Count == 1))
                                {
                                    <div class="col-lg-12 px-0">
                                        <partial name="_ProductTierPrices" model="Model.TierPrices" />
                                    </div>
                                }
                                <div class="col-lg-12 px-0">
                                    @{
                                        var dataDictPrice = new ViewDataDictionary(ViewData);
                                        dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", Model.Id);
                                        <partial name="_ProductPrice" model="Model.ProductPrice" view-data="dataDictPrice" />
                                    }
                                </div>
                                <div class="generalMarginSupporter">
                                    <!--auction-->
                                    @if (Model.ProductType == ProductType.Auction)
                                    {
                                        var dataDictAuction = new ViewDataDictionary(ViewData);
                                        dataDictAuction.TemplateInfo.HtmlFieldPrefix = string.Format("auction_{0}", Model.Id);
                                        <partial name="_AuctionInfo" model="Model" view-data="dataDictAuction" />
                                    }
                                    @{
                                        var dataDictAddToWishlist = new ViewDataDictionary(ViewData);
                                        dataDictAddToWishlist.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", Model.Id);
                                        var dataDictAddToCart = new ViewDataDictionary(ViewData);
                                        dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", Model.Id);
                                    }
                                    <partial name="_AddToCart" model="Model.AddToCart" view-data="dataDictAddToCart" />
                                    <b-btn-group class="mt-2 mb-3 w-100">
                                        @if (Model.ProductType == ProductType.SimpleProduct || Model.ProductType == ProductType.BundledProduct)
                                        {
                                            <partial name="_AddToWishlist" model="Model.AddToCart" view-data="dataDictAddToWishlist" />
                                            <partial name="_CompareProductsButton" model="Model" />
                                        }
                                        @if (Model.EmailAFriendEnabled)
                                        {
                                            <partial name="_ProductEmailAFriendButton" model="Model" />
                                        }
                                        @if (Model.AskQuestionEnabled)
                                        {
                                            <partial name="_ProductAskQuestionButton" model="Model" />
                                        }
                                    </b-btn-group>
                                </div>
                            </div>
                            @if (!String.IsNullOrWhiteSpace(Model.PageShareCode))
                            {
                                <div class="col-12 product-share px-0">
                                    <partial name="_ShareButton" model="Model" />
                                </div>
                            }
                            <vc:widget widget-zone="productdetails_overview_bottom" additional-data="@Model.Id"></vc:widget>
                        </b-col>
                    </b-row>
                </b-container>

                <b-col cols="12" class="px-0 my-3">
                    <div>
                        <b-tabs content-class="mt-3" align="center">
                            <b-tab title="@T("Products.Description")" active>
                                @Html.Raw(Model.FullDescription)
                            </b-tab>
                            @if (Model.ProductTags.Any())
                            {
                                <b-tab title="@T("Products.Tags")">
                                    <partial name="_ProductTags" model="Model.ProductTags" />
                                </b-tab>
                            }
                            @if (Model.ProductSpecifications.Any())
                            {
                                <b-tab title="@T("Products.Specs")">
                                    <partial name="_ProductSpecifications" model="Model.ProductSpecifications" />
                                </b-tab>
                            }
                            @if (Model.ProductReviewOverview.AllowCustomerReviews)
                            {
                                <b-tab id="review-tab" title="@T("Products.Reviews")" :active="active ? true : false">
                                    @await Component.InvokeAsync("ProductReviews", new { productId = Model.Id })
                                </b-tab>
                            }
                            @if (Model.AskQuestionOnProduct)
                            {
                                <b-tab title="@T("Products.ContactUs")">
                                    <partial name="_AskQuestionOnProduct" model="Model.ProductAskQuestion" />
                                </b-tab>
                            }
                        </b-tabs>
                    </div>
                </b-col>
                <vc:products-also-purchased product-id="@Model.Id" product-thumb-picture-size="null"></vc:products-also-purchased>
                <vc:related-products product-id="@Model.Id" product-thumb-picture-size="null"></vc:related-products>
                <vc:similar-products product-id="@Model.Id" product-thumb-picture-size="null"></vc:similar-products>
            </div>
        </form>
        <vc:widget widget-zone="productdetails_bottom" additional-data="@Model.Id"></vc:widget>
    </div>
</b-modal>
<div class="script-tag">
    <resources asp-type="ScriptHeader" />
    <resources asp-type="ScriptFooter" />
</div>